home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / help_prg.zip / HELP.PRG
Text File  |  1995-03-28  |  6KB  |  223 lines

  1. //....................................................................
  2. //
  3. //   Program Name: HELP.PRG          Copyright: BrayWorth Pty Ltd
  4. //   Date Created: 03/14/95          Author   : David Bray
  5. //                                   Telephone: (0011) (075) 982108
  6. //   Note: Tab Stops := 9
  7. //
  8. //   Compile Clipper help /n/w
  9. //   Link    RTLink  File Help
  10. //      or   Blinker File Help
  11. //....................................................................
  12.  
  13. /*
  14.  
  15.     :Hi:
  16.  
  17. To:
  18. All who want on-line help !
  19.  
  20. From:
  21. David Bray
  22. Clipper Programmer
  23. Brayworth Pty Ltd
  24. PO Box 132 Palm Beach Queensland Australia 4221
  25. Tel/Fax International 64-75-982108
  26. Compuserve  100032,23
  27.  
  28.     :OverView:
  29.  
  30.     On Line Documentation
  31.     ---------------------
  32.  
  33. This utility program will put your selected reference at the top of
  34. the screen using memoedit().
  35.  
  36. I recently purchased a hypertext product for no other reason than to
  37. create my own Nortons Guides.  After converting the documentation
  38. from Word-Perfect (some time earlier it was converted from Wordstar),
  39. hyperlinks were created and, after showing off the finished product
  40. to a programming buddy, I was pleased to receive a pat on the back.
  41.  
  42. It looked and worked superbly and in my next installation I
  43. faithfully installed the product, and showed them client how to use
  44. it. The client was also supplied with the printed manual for good
  45. measure.
  46.  
  47. After one month I re-attended the site for a standard follow up
  48. visit. They had lost the manual and forgotten about the hypertext,
  49. fortunately they were still using the program !!
  50.  
  51. So what do you do ?
  52.  
  53. The Task
  54. --------
  55.  
  56. To have on-line help, and, without re-typing a sinlge line of the
  57. manual, have the option to supply a printed manual.
  58.  
  59. The Answer
  60. ----------
  61.  
  62. There is only one text format - ASCII.
  63.     No other text format is universally acceptable.
  64.  
  65. The help must be available as a menu option so the user can see it,
  66. therefore it must be part of the clipper program.
  67.  
  68. The text must be printable, and the simpler the printing process the
  69. better, preferably;
  70.     "Copy Manual.Txt LPT1".
  71.  
  72. The Text can also read into most word-processors for quick formating
  73. and printing.
  74.  
  75. The Method
  76. ----------
  77.  
  78. Create a straight ASCII text file. Memoedit is an Ok editor (Brief is
  79. better), it is best to replace the soft Carriage Returns with Hard
  80. ones.
  81.  
  82. Put References in the text, I like to add a colon prefix and suffix
  83. to references to make them unique, something like this;
  84.  
  85.     :Suppliers File:
  86.  
  87.     The Suppliers file holds suppliers !!
  88.  
  89. Add the activation code to your program
  90.  
  91.     Proc SupplierEnquiry()
  92.  
  93.         local bF1   :=  ;
  94.             SetKey( K_F1,    ;
  95.                 { || Manual( ':Suppliers File:' )   ;
  96.             } )
  97.  
  98.         // do your stuff clipper programmer
  99.  
  100.         setkey( K_F1, bF1 )
  101.     Return
  102.  
  103. Create the memoedit positioning utility (this example was created
  104. from sample models in pe.prg)
  105.  
  106.     :Code:
  107. //..........................................
  108. //
  109. //   Program Name: MANUAL.PRG
  110. //   Author      : David Bray
  111. //
  112. //...........................    */
  113.  
  114. #include 'inkey.ch'
  115.  
  116. static cFile    := 'manual.txt'
  117.  
  118. //        :Demo:
  119.  
  120. proc demo
  121.     local cManual    := manualSET( 'Help.Prg' )
  122.     local bKF1    := setkey( K_F1, { || manual( ':Hi:' )        })
  123.     local bKF2    := setkey( K_F2, { || manual( ':OverView:' )    })
  124.     local bKF5    := setkey( K_F5, { || manual( ':Code:' )    })
  125.     local bKF6    := setkey( K_F6, { || manual( ':Demo:' )    })
  126.     local bKF7    := setkey( K_F7, { || manual( ':Manual Change' + ':')})
  127.     local bKF8    := setkey( K_F8, { || manual( ':Reference' + ':' )    })
  128.  
  129.     cls
  130.  
  131.     ? "     Press F1, I'll say Hi"
  132.     ? "     Press F2, See the Overview"
  133.     ?
  134.     ?
  135.     ?
  136.     ? "     Press F5, See the Code"
  137.     ? "         Press F6, See the Demo"
  138.     ? "         Press F7, See how the change the manual"
  139.     ? "         Press F8, See how the to look up reference"
  140.     ?
  141.     ?
  142.  
  143.     wait
  144.  
  145.     setkey( K_F8,bKF8 )
  146.     setkey( K_F7,bKF7 )
  147.     setkey( K_F6,bKF6 )
  148.     setkey( K_F5,bKF5 )
  149.     setkey( K_F2,bKF2 )
  150.     setkey( K_F1,bKF1 )
  151.     manualSET( cManual )
  152. return
  153.  
  154. //        :Manual Change:
  155.  
  156. func manualSET( cNew )
  157.  
  158.     //  function for setting and resetting help file
  159.     local cRet    := cFile
  160.  
  161.     if cNew != nil
  162.         cFile    := cNew
  163.     end
  164. return ( cRet )
  165.  
  166. //        :Reference:'
  167.  
  168. proc manual( cRef )
  169.  
  170.     local t         := 0
  171.     local l         := 0
  172.     local b         := maxrow()
  173.     local r         := maxcol()
  174.     local aRC       := { row(), col() }
  175.     local cScreen   := savescreen()
  176.     local lEdit     := .t.  // .f. on the
  177.                             // distributed version
  178.     local nWidth    := 77
  179.     local nRow      := 1
  180.     local nCol      := 0
  181.     local nPos      := 0
  182.  
  183.     // turn cursor on as a positioning aid
  184.     local nCursor   := setcursor( 1 )
  185.  
  186.     local cColor    := setcolor( 'W/B' )
  187.     local cHead     := '[Manual Enquiry]'
  188.     local cText, cNew, aLC
  189.  
  190.     cls
  191.     @ t,l to b,r
  192.     @ t,(r-l-len(cHead))/2 say cHead
  193.  
  194.     // read in the file ...
  195.     cText   := memoread( cFile )
  196.     if cRef != nil
  197.         // locate the reference
  198.         nPos    := at( cRef, cText )
  199.  
  200.         if nPos > 0
  201.         // what line and column is that in the text ?
  202.             aLC     := MPosToLC( cText,nWidth,nPos )
  203.             nRow    := aLC[ 1 ]
  204.             nCol    := aLC[ 2 ]
  205.         endif
  206.     endif
  207.  
  208.     cNew := memoedit(   cText,              ;
  209.                         t+1,l+1,b-1,r-1,    ;
  210.                         lEdit,,nWidth,,     ;
  211.                         nRow, nCol, 0, nCol )
  212.  
  213.     if lEdit .and. !( cNew == cText )
  214.         // remove soft returns before saving
  215.         memowrit( cFile, hardcr( cNew ) )
  216.     end
  217.  
  218.     Restscreen( ,,,,cScreen )
  219.     setcursor( nCursor )
  220.     setcolor( cColor )
  221.     setpos( aRC[1],aRC[2] )
  222. return
  223.